home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / server~1.zip / _EXITRLS.QC < prev    next >
Text File  |  1996-10-04  |  7KB  |  204 lines

  1. /*
  2. **
  3. ** _exitrls.qc (ExitRules Code, 1.1)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. //==============================================================
  26. //   Defaults
  27. //==============================================================
  28.  
  29. float EXITRULES_FRAGLIMIT = 40; // Players can exit only if at least one 
  30.                                 // player has at least this many frags.
  31.                                 // Must be >= 0
  32. float EXITRULES_TIMELIMIT = 1;  // Players can exit only if at least this many
  33.                                 // minutes passed on the current level.
  34.                                 // Must be >= 0.1
  35.  
  36. //==============================================================
  37. //   ExitRulesInfo
  38. //==============================================================
  39.  
  40. void(entity player) ExitRulesInfo =
  41. {
  42.   if (!USE_MODULE_EXITRULES) return;
  43.   
  44.               // 123456789#123456789#123456789#12345678
  45.   sprint(player,"£");
  46.   sprint(player," ExitRules");
  47.   sprint(player,            " restricts exiting.\n");
  48.   sprint(player,"  Type 'help-exitrules' for help.\n");
  49. };
  50.  
  51. //==============================================================
  52. //   ExitRulesInit
  53. //==============================================================
  54.  
  55. void(entity player) ExitRulesInit =
  56. {
  57.   if (!USE_MODULE_EXITRULES) return;
  58.   
  59.   stuffcmd(player,"alias help-exitrules \"impulse 210\";\n");
  60. };
  61.  
  62. //==============================================================
  63. //   ExitRulesActiveMessage
  64. //==============================================================
  65.  
  66. void(entity player) ExitRulesActiveMessage =
  67. {
  68.   if (!USE_MODULE_EXITRULES) return;
  69.   
  70.               // 123456789#123456789#123456789#12345678
  71.   sprint(player,"  ExitRules     (help-exitrules)\n");
  72. };
  73.  
  74. //==============================================================
  75. //   ExitRulesHelp
  76. //==============================================================
  77.  
  78. void(entity player) ExitRulesHelp =
  79. {
  80.   if (!USE_MODULE_EXITRULES) return;
  81.   
  82.               // 123456789#123456789#123456789#12345678
  83.   sprint(player,"ExitRules:");
  84.   sprint(player,           " imposes restrictions on\n");
  85.   sprint(player,"exiting a level. Current rules are:\n");
  86.   sprint(player,"  ");
  87.   ExitRulesLevelInfo(player);
  88.   if (USE_MODULE_VOTE && USE_SUBMODULE_VOTE_EXITRULES) {     //#jp#(Vote)
  89.                 // 123456789#123456789#123456789#12345678    //#jp#(Vote)
  90.     sprint(player,"ExitRules may be disabled by voting\n");    //#jp#(Vote)
  91.     sprint(player,"via the command 'vote-exitrules'.\n");    //#jp#(Vote)
  92.   }                                //#jp#(Vote)
  93. };
  94.  
  95. //==============================================================
  96. //   ExitRulesLevelInfo
  97. //==============================================================
  98.  
  99. void(entity player) ExitRulesLevelInfo =
  100. {
  101.   if (!USE_MODULE_EXITRULES) return;
  102.   
  103.   if (exitrules_status == EXITRULES_STATUS_TIGHT) {
  104.     local string tmpstr;
  105.     // 123456789#123456789#123456789#12345678
  106.     sprint(player,"ExitRules: ");
  107.     sprint(player,            "before you can exit one\n");
  108.     sprint(player,"player must have ");
  109.     tmpstr = ftos(exitrules_fraglimit);
  110.     sprint(player,tmpstr);
  111.     sprint(player," frags.\n");
  112.   } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  113.     sprint(player,"ExitRules:");
  114.     sprint(player,            " you can exit.\n");
  115.   }
  116. };
  117.  
  118. //==============================================================
  119. //   ExitRulesSetValues
  120. //==============================================================
  121.  
  122. void() ExitRulesSetValues =
  123. {
  124.   if (exitrules_inited) return;
  125.   exitrules_inited = 1;
  126.   
  127.   if (!USE_MODULE_EXITRULES) return;
  128.   
  129.   // exitrules are not sensible if 'noexit' is active
  130.   if (cvar("noexit")) {
  131.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  132.     // disable exitrules for start level and levels with no exit 
  133.   } else if   (world.model == "maps/start.bsp") {
  134.     exitrules_status    = EXITRULES_STATUS_SOFT;
  135.   } else if (world.model == "maps/end.bsp") {
  136.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  137.   } else if (world.model == "maps/dm1.bsp") {
  138.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  139.   } else if (world.model == "maps/dm2.bsp") {
  140.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  141.   } else if (world.model == "maps/dm3.bsp") {
  142.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  143.   } else if (world.model == "maps/dm4.bsp") {
  144.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  145.   } else if (world.model == "maps/dm5.bsp") {
  146.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  147.   } else if (world.model == "maps/dm6.bsp") {
  148.     exitrules_status    = EXITRULES_STATUS_DISABLED;
  149.   } else {
  150.     exitrules_status    = EXITRULES_STATUS_TIGHT;
  151.     exitrules_fraglimit = EXITRULES_FRAGLIMIT;
  152.     exitrules_timelimit = EXITRULES_TIMELIMIT;
  153.   }
  154. };
  155.  
  156. //==============================================================
  157. //   ExitRulesExitingIsNotAllowed
  158. //==============================================================
  159.  
  160. float(entity player) ExitRulesExitingIsNotAllowed =
  161. {
  162.   if (!USE_MODULE_EXITRULES) return(0);
  163.   
  164.   player.exitrules_death = 2;
  165.   if (exitrules_status == EXITRULES_STATUS_DISABLED) {
  166.     player.exitrules_death = 0;
  167.   } else if (exitrules_status == EXITRULES_STATUS_SOFT) {
  168.     player.exitrules_death = 0;
  169.   } else if (exitrules_maxfrags >= exitrules_fraglimit) {
  170.     player.exitrules_death = 0;
  171.   } 
  172.   if (!player.exitrules_death) {
  173.     if (time < exitrules_timelimit*60) {
  174.       player.exitrules_death = 1;
  175.     }
  176.   }
  177.   return(player.exitrules_death);
  178. };
  179.  
  180. //==============================================================
  181. //   ExitRulesClientObituary
  182. //==============================================================
  183.  
  184. void(entity player) ExitRulesClientObituary =
  185. {
  186.   if (player.exitrules_death == 1) {
  187.     bprint (player.netname);
  188.     bprint(" tried to exit before ");
  189.     bprint(ftos(exitrules_timelimit));
  190.     if (exitrules_timelimit == 1) bprint(" minute");
  191.     else                          bprint(" minutes");
  192.     bprint(" had passed on this level.\n");
  193.   } else {
  194.     bprint (player.netname);
  195.     bprint(" tried to exit before ");
  196.     bprint(ftos(exitrules_fraglimit));
  197.     bprint(" frags were reached.\n");
  198.    }
  199.   player.exitrules_death = 0;
  200. };
  201.  
  202.  
  203.  
  204.